package standino.velocity.db.db2;

import java.util.List;

import standino.velocity.db.db2.template.Generator;

public class GenSQL {

	public void gen(String defFile,String destDir){

		TableBuilder builder = new TableBuilder();
		builder.build(defFile);
		Generator gn = new Generator(destDir+"/"+builder.getTable().getName()+".sql","table.vm");
		gn.gen("table", builder.getTable());
		List<SP> sp = builder.getSps();
		for(SP s:sp){
			gn = new Generator(destDir+"/"+s.getName()+".sql",s.getType()+".vm");
			gn.gen("sp", s);
		}

	}

	public static void main(String[] args){
		GenSQL gn = new GenSQL();
        if(args.length<2){
            System.out.println("java -jar Velocity.jar table.def  c:\\");
        }else{
            gn.gen(args[0],args[1]);
        }
	}
}
